package com.qingluan.web;

import org.json.JSONObject;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.qingluan.web.AsyncRecive.ListenJsonResult;

public class HttpTemplate {

	/*
	 * 
	 * 
	 * 
	 * this is a success http template ..
	 * you just need to fill some para to this method
	 * you can send info to remote server by 'POST' method
	 * tips :
	 * 		you must use json pass some data.
	 * 		else ,will occur some strange error log
	 * 
	 * 
	 * 
	 * 
	 * 
	 */
	public static void Post(String url,String key,JSONObject value , final ListenJsonResult listen){
		AsyncHttpClient client = new AsyncHttpClient();
		RequestParams params  = new RequestParams();
		params.put(key, value.toString());
		client.post(url,params, new AsyncHttpResponseHandler(){
			@Override
			public void onSuccess(int statusCode, String content) {
				// TODO Auto-generated method stub
				listen.success(content);
			}
			
			@Override
			public void onFailure(int statusCode, Throwable error,
					String content) {
				// TODO Auto-generated method stub
				listen.fail(error.toString()+"\n"+content);
			}
		});
	}
	
	
	/*
	 * 
	 */
	

}

